package com.iterator.bean.wechat.order.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.iterator.bean.wechat.order.OrderStatusEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author : L
 * @ProjectName : project-2
 * @Date : 1/12/2021
 * @Description :
 */
@Data
public class OrderInfoBeanVO {
    /**
     * consignee : 松哥
     * address : 湖北省 武汉市 洪山区 花山街道软件新城2期
     * addTime : 2021-01-12 14:23:17
     * orderSn : 20210112846231
     * actualPrice : 1001
     * mobile : 15976753826
     * orderStatusText : 未付款
     * goodsPrice : 1001
     * couponPrice : 0
     * id : 27
     * freightPrice : 0
     * handleOption : {"cancel":true,"delete":false,"pay":true,"comment":false,"confirm":false,"refund":false,"rebuy":false}
     */

    private String consignee;
    private String address;
    @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss",timezone = "GMT+8")
    private Date addTime;
    private String orderSn;
    private BigDecimal actualPrice;
    private String mobile;
    private String orderStatusText;
    private BigDecimal goodsPrice;
    private BigDecimal couponPrice;
    private int id;
    private BigDecimal freightPrice;
    private HandleOptionBeanVO handleOption = new HandleOptionBeanVO();

    public void setOrderStatusText(Short orderStatus) {
        if (orderStatus == 101) {
            orderStatusText = OrderStatusEnum.UN_PAID.getStatusText();
//            handleOption.setCancel(true);
//            handleOption.setDelete(true);
//            handleOption.setPay(true);
        } else if (orderStatus == 102) {
            orderStatusText = OrderStatusEnum.USER_CANCELED.getStatusText();
//            handleOption.setDelete(true);
        } else if (orderStatus == 103) {
            orderStatusText = OrderStatusEnum.SYSTEM_CANCELED.getStatusText();
//            handleOption.setDelete(true);
        } else if (orderStatus == 201) {
            orderStatusText = OrderStatusEnum.PAID.getStatusText();
//            handleOption.setRefund(true);
        } else if (orderStatus == 202) {
            orderStatusText = OrderStatusEnum.REFUND_REQUESTED.getStatusText();
        } else if (orderStatus == 203) {
            orderStatusText = OrderStatusEnum.REFUNDED.getStatusText();
        } else if (orderStatus == 301) {
            orderStatusText = OrderStatusEnum.SHIPPED.getStatusText();
//            handleOption.setConfirm(true);
        } else if (orderStatus == 401) {
            orderStatusText = OrderStatusEnum.USER_RECEIPTED.getStatusText();
//            handleOption.setDelete(true);
//            handleOption.setComment(true);
//            handleOption.setRebuy(true);
        } else if (orderStatus == 402) {
            orderStatusText = OrderStatusEnum.SYSTEM_RECEIPTED.getStatusText();
//            handleOption.setDelete(true);
//            handleOption.setComment(true);
//            handleOption.setRebuy(true);
        }
    }
    public void setHandleOption(Short orderStatus) {
        if (orderStatus == 101) {
            handleOption.setCancel(true);
            handleOption.setDelete(true);
            handleOption.setPay(true);
        } else if (orderStatus == 102) {
            handleOption.setDelete(true);
        } else if (orderStatus == 103) {
            handleOption.setDelete(true);
        } else if (orderStatus == 201) {
            handleOption.setRefund(true);
        }
//        else if (orderStatus == 202) {
//        } else if (orderStatus == 203) {
//        }
        else if (orderStatus == 301) {
            handleOption.setConfirm(true);
        } else if (orderStatus == 401) {
            handleOption.setDelete(true);
            handleOption.setComment(true);
            handleOption.setRebuy(true);
        } else if (orderStatus == 402) {
            handleOption.setDelete(true);
            handleOption.setComment(true);
            handleOption.setRebuy(true);
        }
    }

}